package gui;

import javax.swing.*;
import java.awt.*;

public class LoginWin extends JFrame {
    JPanel jP1,jp2,jp3,jp4;
    JLabel label1,label2;
    JButton button1;
//    JButton button2;
    JTextField admin;
    JPasswordField password;
    JRadioButton r1,r2;

    public LoginWin(){
        init();

        setTitle("登录JBook");
        setSize(300,200);
        setVisible(true);   //设置为可见
        setResizable(false);    //禁用用户调整界面大小
        setLocationRelativeTo(null);    //窗口居中
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //终止应用运行
    }
    void init(){
        setLayout(new GridLayout(4,1));
        jP1 = new JPanel();
        jp2 = new JPanel();
        jp3 = new JPanel();
        jp4 = new JPanel();

        label1 = new JLabel("账 号");
        label2 = new JLabel("密 码");

        admin = new JTextField(10);
        password = new JPasswordField(10);

        button1 = new JButton("登录");
//        button2 = new JButton("读者注册");

        jP1.add(label1);
        jP1.add(admin);

        jp2.add(label2);
        jp2.add(password);

        ButtonGroup buttonGroup=new ButtonGroup();
        r1=new JRadioButton("读者");
        r2=new JRadioButton("管理员");
        buttonGroup.add(r1);
        buttonGroup.add(r2);
        jp3.add(r1);
        jp3.add(r2);

        jp4.add(button1);
        add(jP1);
        add(jp2);
        add(jp3);
        add(jp4);
    }
    public JTextField getAdmin(){
        return this.admin;
    }
    public AbstractButton getLoginButton1() {return button1;}
    public JPasswordField getPasswordField() {
        return this.password;
    }
    public JRadioButton getR1() {
        return r1;
    }
    public JRadioButton getR2() {
        return r2;
    }
    public static void main(String[] args) {
        new LoginWin();
    }
}

